﻿using System;
using System.Reflection;

namespace NativeCode.Web.Controls.Data
{
	public static class DataBinderHelper
	{
		public static string GetPropertyValue(object instance, string propertyName)
		{
			Type type = instance.GetType();
			PropertyInfo propertyInfo = type.GetProperty(propertyName);
			if (propertyInfo != null)
			{
				object value = propertyInfo.GetValue(instance, new object[] {});
				if (value != null)
				{
					return value.ToString();
				}
			}

			return null;
		}
	}
}